package cn.edu.scau.cmi.chenjiale.composite.safe;

import java.util.ArrayList;
import java.util.List;

/**
 * 安全模式的组合类
 * 
 * 
 * @author chen
 * @date 2019/04/16
 *
 */
public class SafeOrganizationComposite extends SafeOrganization {

	private List<SafeOrganization> childList = new ArrayList<SafeOrganization>();

	public SafeOrganizationComposite() {
	}

	public SafeOrganizationComposite(String name) {
		super(name);
	}

	public boolean addChild(SafeOrganization organization) {
		this.childList.add(organization);
		return true;
	}

	public boolean removeChild(SafeOrganization organization) {
		this.childList.add(organization);
		return true;
	}

	@Override
	public String display() {
		StringBuilder builder = new StringBuilder();
		builder.append("组织名称：" + name + "\n");
		for (SafeOrganization organization : childList) {
			String childName = organization.display();
			builder.append("  " + childName + "\n");
		}
		return builder.toString();
	}

}
